//
//  Qianbao_chongzhiViewController.m
//  tianjin
//
//  Created by 鞠超 on 16/8/11.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Qianbao_chongzhiViewController.h"

@interface Qianbao_chongzhiViewController () <UIScrollViewDelegate, UITextFieldDelegate>

@property (nonatomic, strong) UIScrollView * scrollView;

//
@property (nonatomic, strong) UITextField * text_jine;
//
@property (nonatomic, strong) UIButton * btn_zhifubo;
@property (nonatomic, strong) UIButton * btn_weixin;

@end

@implementation Qianbao_chongzhiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void)p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    _topView.backgroundColor = [UIColor blackColor];
    
    _lblTitle.text = @"充值";
    _lblTitle.textColor = [UIColor whiteColor];
    _lblTitle.font = [UIFont systemFontOfSize:19];
    
    UIImageView * image_return = [[UIImageView alloc] initWithFrame:CGRectMake(15, 32, 10, 20)];
    image_return.image = [UIImage imageNamed:@"zuofanhui@2x.png"];
    [_topView addSubview:image_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 20, 35, 44);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.scrollView.contentSize = CGSizeMake(0, SCREEN_HEIGHT - 60);
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    
    //金额
    UIView * view_1 = [[UIView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 50)];
    view_1.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_1];
    
    UIView * view_line1 = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    view_line1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_1 addSubview:view_line1];
    
    UILabel * lbl_1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 17.5, 70, 15)];
    lbl_1.text = @"充值金额";
    lbl_1.font = [UIFont systemFontOfSize:17];
    [view_1 addSubview:lbl_1];
    
    self.text_jine = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(lbl_1.frame) + 10, 13, SCREEN_WIDTH - CGRectGetMaxX(lbl_1.frame) - 20, 24)];
    self.text_jine.delegate = self;
    self.text_jine.placeholder = @"请输入充值金额";
    self.text_jine.clearButtonMode = UITextFieldViewModeAlways;
    self.text_jine.font = [UIFont systemFontOfSize:17];
    self.text_jine.returnKeyType = UIReturnKeyDone;
    [view_1 addSubview:self.text_jine];
    
    
    //
    UIView * view_2 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(view_1.frame) + 10, SCREEN_WIDTH, 50)];
    view_2.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_2];
    
    UIView * view_line2 = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    view_line2.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_2 addSubview:view_line2];
    
    UILabel * lbl_2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 17.5, 70, 15)];
    lbl_2.text = @"支付方式";
    lbl_2.font = [UIFont systemFontOfSize:17];
    [view_2 addSubview:lbl_2];
    
    
    //
    UIView * view_3 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(view_2.frame), SCREEN_WIDTH, 50)];
    view_3.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_3];
    
    UIView * view_line3 = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    view_line3.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_3 addSubview:view_line3];
    
    UIImageView * image_3 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12.5, 25, 25)];
    image_3.image = [UIImage imageNamed:@"zhifubo@2x.png"];
    [view_3 addSubview:image_3];
    
    UILabel * name_3 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_3.frame) + 10, 17.5, 100, 15)];
    name_3.text = @"支付宝支付";
    name_3.font = [UIFont systemFontOfSize:15];
    [view_3 addSubview:name_3];
    
    self.btn_zhifubo = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_zhifubo.frame = CGRectMake(SCREEN_WIDTH - 10 - 25, 12.5, 25, 25);
    [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    [view_3 addSubview:self.btn_zhifubo];
    [self.btn_zhifubo addTarget:self action:@selector(btn_zhifuboAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //
    UIView * view_4 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(view_3.frame), SCREEN_WIDTH, 50)];
    view_4.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_4];
    
    UIView * view_line4 = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    view_line4.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_4 addSubview:view_line4];
    
    UIImageView * image_4 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12.5, 25, 25)];
    image_4.image = [UIImage imageNamed:@"weixin@2x.png"];
    [view_4 addSubview:image_4];
    
    UILabel * name_4 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_4.frame) + 10, 17.5, 100, 15)];
    name_4.text = @"微信支付";
    name_4.font = [UIFont systemFontOfSize:15];
    [view_4 addSubview:name_4];
    
    self.btn_weixin = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_weixin.frame = CGRectMake(SCREEN_WIDTH - 10 - 25, 12.5, 25, 25);
    [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    [view_4 addSubview:self.btn_weixin];
    [self.btn_weixin addTarget:self action:@selector(btn_weixinAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //点击充值
    UIButton * btn_chongzhi = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_chongzhi.frame = CGRectMake(15, CGRectGetMaxY(view_4.frame) + 50, SCREEN_WIDTH - 30, 45);
    btn_chongzhi.backgroundColor = navi_bar_bg_color;
    btn_chongzhi.layer.cornerRadius = 5;
    [btn_chongzhi setTitle:@"立即充值" forState:(UIControlStateNormal)];
    [btn_chongzhi setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    btn_chongzhi.titleLabel.font = [UIFont systemFontOfSize:17];
    [self.scrollView addSubview:btn_chongzhi];
    
    [btn_chongzhi addTarget:self action:@selector(btn_chongzhiAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

#pragma mark - 点击充值
- (void )btn_chongzhiAction:(UIButton *)sender
{
    [self.text_jine resignFirstResponder];

    NSLog(@"点击充值");
}

#pragma mark - 支付宝
- (void )btn_zhifuboAction:(UIButton *)sender
{
    if([sender.currentBackgroundImage isEqual:[UIImage imageNamed:@"weixuanzhong@2x.png"]])
    {
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"xuanzhong@2x.png"] forState:(UIControlStateNormal)];
        //
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
    else
    {
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
}

#pragma mark - 微信
- (void )btn_weixinAction:(UIButton *)sender
{
    if([sender.currentBackgroundImage isEqual:[UIImage imageNamed:@"weixuanzhong@2x.png"]])
    {
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"xuanzhong@2x.png"] forState:(UIControlStateNormal)];
        //
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
    else
    {
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
}

#pragma mark - scrollView代理
- (void )scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [self.text_jine resignFirstResponder];
}

#pragma mark - textfiled代理
- (BOOL )textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    return YES;
}







@end
